package com.example.mall.mapper;

import com.example.mall.pojo.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsMapper {

    @Select("select * from sp_goods  where is_del='0'")
    List<Goods> getGoodsList();

    @Update("update sp_goods set is_del='1' where goods_id=#{goods_id} and is_del='0'" )
    int deleteGoods(Integer id);

    @Select("select * from sp_goods  where goods_name like '%' #{goods_name} '%' and is_del='0'")
    List<Goods> getGoodByName(String goodsName);

    @Select("select * from sp_goods where goods_name =#{goods_name} and is_del='0'")
    Goods getGoodsName(String goodsName);

    @Insert("insert into sp_goods(goods_name,goods_price,goods_number,goods_weight,cat_id,goods_introduce,goods_big_logo,goods_small_logo,goods_state,add_time,upd_time,hot_mumber,is_promote) values(#{goods_name},#{goods_price},#{goods_number},#{goods_weight},#{cat_id},#{goods_introduce},#{goods_big_logo},#{goods_small_logo},#{goods_state},#{add_time},#{upd_time},#{hot_mumber},#{is_promote})")
    int addGoods(@Param("goods_name") String goods_name,@Param("goods_price") Integer goods_price,@Param("goods_number") Integer goods_number,@Param("goods_weight") Short goods_weight,@Param("cat_id") Integer cat_id,
                 @Param("goods_introduce") String goods_introduce,@Param("goods_big_logo") String goods_big_logo,@Param("goods_small_logo") String goods_small_logo,
                 @Param("goods_state") Integer goods_state,@Param("add_time") Integer add_time,@Param("upd_time") Integer upd_time,@Param("hot_mumber") Integer hot_mumber,@Param("is_promote") Short is_promote);
}
